# 467 中等：环绕字符串中唯一的子字符串

def findSubstringInWraproundString(p):
    dp = [0 for _ in range(26)]
    num = 0
    for i, ch in enumerate(p):
        if i > 0 and (ord(ch) - ord(p[i - 1])) % 26 == 1:
            num += 1
        else:
            num = 1
        dp[ord(ch) - 97] = max(dp[ord(ch) - 97], num)

    return sum(dp)


print(findSubstringInWraproundString('zababcc'))
